<%@ page language="java" contentType="text/html; charset=utf-8"	pageEncoding="utf-8"%>
<%@ page import="java.sql.*"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=uft-8">
<title>登录检验</title>

</head>

<body>
	<%
		request.setCharacterEncoding("utf-8");
		String username = request.getParameter("username");
		String passwords = request.getParameter("pwd");
		boolean flag = false;
		PreparedStatement sql = null;
		ResultSet rs = null;
		Connection conn = null;
	%>

	<%
		String driver = "com.mysql.jdbc.Driver";
		String url = "jdbc:mysql://localhost:3306/jsp";
		String use = "root";
		String password = "root";
		Class.forName(driver);
		conn = DriverManager.getConnection(url, use, password);
		sql = conn.prepareStatement("select * from tb_student where username=? and passwords=?");
		sql.setString(1, username);
		sql.setString(2, passwords);
		rs = sql.executeQuery();
		if (rs.next()) {
			flag = true;
		}
		rs.close();
		sql.close();
		conn.close();
	%>

	<%
		if (flag == true) {
	%>
	<jsp:forward page="loginSuccess.jsp" />
	<%
		} else if (flag == false) {
	%>
	<jsp:forward page="loginFail.jsp" />
	<%
		}
	%>
  </body>
</html>